aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/[lang=lang]/+page.server.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/[lang=lang]/+page.server.ts')
-rw-r--r--src/routes/[lang=lang]/+page.server.ts54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/routes/[lang=lang]/+page.server.ts b/src/routes/[lang=lang]/+page.server.ts
index a647cfe..c2284ee 100644
--- a/src/routes/[lang=lang]/+page.server.ts
+++ b/src/routes/[lang=lang]/+page.server.ts
@@ -1,29 +1,31 @@
-import { sanity } from '$lib/sanity-client';
-import type { PageServerLoad } from './$types';
+import { sanity } from "$lib/sanity-client";
+import type { PageServerLoad } from "./$types";
import groq from "groq";
-import type { ContactModel } from './sections/contact.svelte';
-import { fromLocalizedString } from '$lib/utils';
-import type { HeroModel } from './sections/hero.svelte';
-import type { DescriptionModel } from './sections/description.svelte';
+import type { ContactModel } from "./sections/contact.svelte";
+import { fromLocalizedString } from "$lib/utils";
+import type { HeroModel } from "./sections/hero.svelte";
+import type { DescriptionModel } from "./sections/description.svelte";
export const load = (async ({ locals }) => {
- const contactSection = await sanity.fetch(groq`*[_type == "contact"][0]`);
- const heroSection = await sanity.fetch(groq`*[_type == "hero"][0]`);
- const descriptionSection = await sanity.fetch(groq`*[_type == "description"][0]`);
- return {
- contact: {
- phone: fromLocalizedString(contactSection.phone, locals.locale),
- email: fromLocalizedString(contactSection.email, locals.locale),
- phoneHours: fromLocalizedString(contactSection.phoneHours, locals.locale),
- addressLines: contactSection.addressLines.map((el: string | object) => fromLocalizedString(el, locals.locale)),
- } as ContactModel,
- hero: {
- title: heroSection.title,
- content: heroSection.content
- } as HeroModel,
- description: {
- title: descriptionSection.title,
- content: descriptionSection.content
- } as DescriptionModel
- };
-}) satisfies PageServerLoad; \ No newline at end of file
+ const contactSection = await sanity.fetch(groq`*[_type == "contact"][0]`);
+ const heroSection = await sanity.fetch(groq`*[_type == "hero"][0]`);
+ const descriptionSection = await sanity.fetch(groq`*[_type == "description"][0]`);
+ const products = await sanity.fetch(groq`*[_type == "product"]`);
+ return {
+ contact: {
+ phone: fromLocalizedString(contactSection.phone, locals.locale),
+ email: fromLocalizedString(contactSection.email, locals.locale),
+ phoneHours: fromLocalizedString(contactSection.phoneHours, locals.locale),
+ addressLines: contactSection.addressLines.map((el: string | object) => fromLocalizedString(el, locals.locale)),
+ } as ContactModel,
+ hero: {
+ title: heroSection.title,
+ content: heroSection.content,
+ } as HeroModel,
+ description: {
+ title: descriptionSection.title,
+ content: descriptionSection.content,
+ } as DescriptionModel,
+ products: products
+ };
+}) satisfies PageServerLoad;